#include "TaskSchedulerStrategy.h"

using namespace threadpool;

bool
DefaultTaskSchedulerStrategy::operator()(const std::shared_ptr<Task> &left, const std::shared_ptr<Task> &right) const {
    if (left->getType() == "TimedTask") {
        if (right->getType() != "TimedTask") {
            return false;
        } else {
            return left->getPriority() < right->getPriority();
        }
    } else if (right->getType() == "TimedTask") {
        return true;
    }
    if (left->getType() == "PeriodicTask") {
        if (right->getType() != "PeriodicTask") {
            return false;
        } else {
            return left->getPriority() < right->getPriority();
        }
    } else if (right->getType() == "PeriodicTask") {
        return true;
    }
    if (left->getType() == "SuicideTask") {
        if (right->getType() != "SuicideTask") {
            return false;
        } else {
            return left->getPriority() < right->getPriority();
        }
    } else if (right->getType() == "SuicideTask") {
        return true;
    }
    return left->getPriority() < right->getPriority();
}